/**
 * 
 */
package com.lehecai.core.api.partner;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.lehecai.core.api.AbstractApiResultBean;
import com.lehecai.core.lottery.LotteryType;

/**
 * @author He Wang
 * 数据项彩种
 */
public class PartnerDataApiLottery extends AbstractApiResultBean {
	
	public static final String QUERY_DATA_API_ID = "dataapi_id";
	public static final String QUERY_LOTTERY_TYPE = "lottery_type";
	
	public static final String SET_LOTTERY_TYPE = "lottery_type";
	public static final String SET_CUSTOM_SHOWNAME = "custom_showname";
	public static final String SET_PHASET_TYPE = "phasetype";
	public static final String SET_CATEGORY = "category";
	public static final String SET_DESCRIPTION = "description";

	private Integer dataApiId;		    //数据项id
	private LotteryType lotteryType;    //彩种
	private String customShowName;      //显示名称
	private String phaseType;		    //彩期格式
	private String category;	        //分类
	private String description;         //描述文字

	public static PartnerDataApiLottery convertFromJSONObject(JSONObject object) {
		if (object == null) {
			return null;
		}
		PartnerDataApiLottery partnerDataApiLottery = new PartnerDataApiLottery();
		if (!isNull(object, QUERY_DATA_API_ID)) {
			partnerDataApiLottery.setDataApiId((getInt(object, QUERY_DATA_API_ID)));
		}
		if (!isNull(object, SET_LOTTERY_TYPE)) {
			partnerDataApiLottery.setLotteryType(LotteryType.getItem(getInt(object, SET_LOTTERY_TYPE)));
		}
		if (!isNull(object, SET_CUSTOM_SHOWNAME)) {
			partnerDataApiLottery.setCustomShowName(getString(object, SET_CUSTOM_SHOWNAME));
		}
		if (!isNull(object, SET_PHASET_TYPE)) {
			partnerDataApiLottery.setPhaseType(getString(object, SET_PHASET_TYPE));
		}
		if (!isNull(object, SET_CATEGORY)) {
			partnerDataApiLottery.setCategory(getString(object, SET_CATEGORY));
		}
		if (!isNull(object, SET_DESCRIPTION)) {
			partnerDataApiLottery.setDescription(getString(object, SET_DESCRIPTION));
		}

		return partnerDataApiLottery;
	}
	
	public static List<PartnerDataApiLottery> convertFromJSONArray(JSONArray array) {
		if (array == null) {
			return null;
		}
		List<PartnerDataApiLottery> list = new ArrayList<PartnerDataApiLottery>();
		for (Iterator<?> iterator = array.iterator(); iterator.hasNext();) {
			JSONObject object = (JSONObject) iterator.next();
			list.add(convertFromJSONObject(object));
		}
		return list;
	}


	public void clear() {
		dataApiId = null;
	}

	public LotteryType getLotteryType() {
		return lotteryType;
	}

	public void setLotteryType(LotteryType lotteryType) {
		this.lotteryType = lotteryType;
	}

	public String getCustomShowName() {
		return customShowName;
	}

	public void setCustomShowName(String customShowName) {
		this.customShowName = customShowName;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setPhaseType(String phaseType) {
		this.phaseType = phaseType;
	}

	public String getPhaseType() {
		return phaseType;
	}

	public void setDataApiId(Integer dataApiId) {
		this.dataApiId = dataApiId;
	}

	public Integer getDataApiId() {
		return dataApiId;
	}
	
}
